package com.tm.util;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CookieUtils {
	
	public static String getCookie(HttpServletRequest request, String cookieName) {
		String val = "";
		if(request.getCookies() != null){
	        for(Cookie cookie : request.getCookies()){
	            if(cookie.getName().equals(cookieName))
	            val = cookie.getValue();
	        } 
	    }
		return val; 
	}
	
	public static void addCookie(HttpServletResponse resp, String name, String value) {
		Cookie cookie = new Cookie(name, value);
		resp.addCookie(cookie);
	}

}
